using System;
using System.Text;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace Crainiate.Data.Persistence
{
    [Serializable]
    public class Queries : List<IQuery>, IQueries, ISerializable, IDeserializationCallback
    {
        //Working variables
        private SerializationInfo _info;

        //Constructors
		public Queries()
		{
		}

        protected Queries(SerializationInfo info, StreamingContext context)
        {
            _info = info;    
        }

        public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        {
            info.AddValue("Queries", ToArray());
        }

        public virtual void OnDeserialization(object sender)
        {
            IQuery[] array = (IQuery[]) _info.GetValue("Queries", typeof(IQuery[]));

            Clear();
            foreach (IQuery query in array)
            {
                Add(query);
            }

            _info = null;
        }
    }
}
